﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using blackhouse.BlackApart.Data;
using blackhouse.BlackApart.Business.Calendar;
using blackhouse.BlackApart.Data.Sql;
using System.Configuration;
using blackhouse.BlackApart.Business;
using blackhouse.BlackApart.Business.Reservations;
using blackhouse.BlackApart.Business.Prices;
using blackhouse.BlackApart.Data.Caching;
using blackhouse.BlackApart.Business.Company;
using blackhouse.AsyncMail.Business.Data;
using mojoPortal.Business.WebHelpers;
using mojoPortal.Business;
using mojoPortal.Web.Framework;
using mojoPortal.Web;

namespace blackhouse.Aparts.Web {
	public class ApartsFactory : Factory {

		public static string GetConnectionString() {
			return ConfigurationManager.AppSettings["MSSQLConnectionString"];
		}

		public override IApartmentPrice GetApartmentPrice(int apartmentId) {
			return new DaApartmentDbPrice(apartmentId, this.GetDataFactory().GetPricesData());
		}

		public override BlackApart.Business.Company.ICompany GetCompany() {
			ICompany company = new DaCompany(
				new CachedCompanyDataAccess(
					new CompanyDataAccess(GetConnectionString()), GetConnectionString()));
			return company;
		}

		public override IASyncMailDataAccess GetASyncMailData() {
			return new SqlASyncMailDataAccess(GetConnectionString());
		}

		public override string GetPreFolderEvaluation() {
			return VirtualFolderEvaluator.VirtualFolderName();

		}

		public override ApartmentSortModel GetSorting() {
			return new ApartsSortModel();
		}

        public override IDataFactory GetDataFactory() {
            return new ApartsDataFactory();
        }

    }
}